[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
getpass() Read a Password
#include <conio.h>
char *getpass(prompt);
const char *prompt; Prompt for password
getpass() writes 'prompt' to the console and then reads a password
from the keyboard. The keys pressed are not echoed to the console.
Returns: A pointer to the password, which is a null-terminated
string of up to eight characters. The password is
stored in a static string that is overwritten by
successive calls to getpass().
-------------------------------- Example ---------------------------------
The following statements prompt the user for a password, and then a
second time to verify that it was entered correctly.
#include <stdio.h> /* for printf */
#include <conio.h> /* for getpass */
main()
{
char password[9];
strcpy(password,getpass("Enter password: "));
printf("\n");
if (strcmp(password,getpass("Enter password again: ")) != 0)
printf("passwords do not agree\n");
else
printf("password OK\n");
}
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson